package main

import (
    "adkr/pkg/crypto"
    "flag"
    "log"
    "os"
    "path/filepath"
)

func main() {
    outDir := flag.String("out", "pycompat_samples", "output directory for samples")
    flag.Parse()
    if err := os.MkdirAll(*outDir, 0o755); err != nil { log.Fatalf("mkdir: %v", err) }

    s := crypto.NewSerializer()
    g1 := crypto.GetG1()
    g2 := crypto.GetG2()
    var zr crypto.ZR; zr.SetRandom()
    var gt crypto.GT; gt.SetRandom()

    samples := map[string]interface{}{
        "g1.bin": g1,
        "g2.bin": g2,
        "zr.bin": zr,
        "gt.bin": gt,
        "list.bin": []interface{}{g1, zr, []byte("hello"), crypto.Tuple{Items: []interface{}{zr, g2}}},
        "tuple.bin": crypto.Tuple{Items: []interface{}{g1, g2, zr, gt}},
        "map.bin": map[string]interface{}{"a": g1, "b": zr, "c": []byte{1,2,3}},
    }

    for name, obj := range samples {
        b, err := s.SerializePyCompat(obj)
        if err != nil { log.Fatalf("serialize %s: %v", name, err) }
        if err := os.WriteFile(filepath.Join(*outDir, name), b, 0o644); err != nil {
            log.Fatalf("write %s: %v", name, err)
        }
    }

    log.Printf("Wrote samples to %s", *outDir)
}






